package cn.edu.xmu.orderpayment.order.model.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Chencheng Liao 22920192204238
 * @date 2021/12/28
 */
public enum CouponState {
    RECEIVED(1,"已领取"),

    USED(2,"已使用"),

    INVALID(3,"已失效");

    private static final Map<Integer, CouponState> COUPON_STATE_MAP;

    static {
        COUPON_STATE_MAP = new HashMap();
        for (CouponState enum1 : values()) {
            COUPON_STATE_MAP.put(enum1.code, enum1);
        }
    }

    private int code;
    private String description;

    CouponState(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static CouponState getCouponStateByCode(Integer code) {
        return COUPON_STATE_MAP.get(code);
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
